﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.utils {
    import flash.geom.*;

    public class GeomUtil {

        private static const MATRIX_MAPPINGS:Array = ["a", "c", "b", "d", "tx", "ty"];

        public function GeomUtil(){
            throw (new Error("You don't instantiate the GeomUtil!"));
        }
        public static function matrixToCSSMatrixString(_arg1:Matrix):String{
            return ((((((((((((("matrix(" + _arg1.a) + ", ") + _arg1.c) + ", ") + _arg1.b) + ", ") + _arg1.d) + ", ") + _arg1.tx) + ", ") + _arg1.ty) + ")"));
        }
        public static function CSSMatrixParametersToMatrix(_arg1:Array):Matrix{
            var _local2:Array = MATRIX_MAPPINGS;
            var _local3:Matrix = new Matrix();
            var _local4:int = _arg1.length;
            while (_local4--) {
                _local3[_local2[_local4]] = parseFloat(_arg1[_local4]);
            };
            return (_local3);
        }
        public static function scaleRectToRect(_arg1:Rectangle, _arg2:Rectangle, _arg3:Boolean=true, _arg4:Boolean=false):void{
            var _local5:Number;
            if (!_arg3){
                _arg1.width = (_arg2.width - _arg1.x);
                _arg1.height = (_arg2.height - _arg1.y);
                return;
            };
            if ((((_arg1.width <= _arg2.width)) && ((_arg1.height <= _arg2.height)))){
                if (!_arg4){
                    return;
                };
                _local5 = Math.min((_arg2.width / _arg1.width), (_arg2.height / _arg1.height));
                _arg1.width = (_arg1.width * _local5);
                _arg1.height = (_arg1.height * _local5);
                return;
            };
            if (_arg1.width <= _arg2.width){
                _local5 = (_arg2.height / _arg1.height);
                _arg1.height = _arg2.height;
                _arg1.width = (_arg1.width * _local5);
            } else {
                if (_arg1.height <= _arg2.height){
                    _local5 = (_arg2.width / _arg1.width);
                    _arg1.width = _arg2.width;
                    _arg1.height = (_arg1.height * _local5);
                } else {
                    _local5 = Math.min((_arg2.width / _arg1.width), (_arg2.height / _arg1.height));
                    _arg1.width = (_arg1.width * _local5);
                    _arg1.height = (_arg1.height * _local5);
                };
            };
        }

    }
}//package reprise.utils 
